package coupon

import (
	"enjoy-shop/api/base"
	"enjoy-shop/formdata"
	coupon2 "enjoy-shop/server/coupon"
	"github.com/gin-gonic/gin"
)

func GoodsOrderCouponList(c *gin.Context) {
	var coupon formdata.GoodsOrderCouponList
	if err := c.ShouldBindJSON(&coupon); err != nil {
		base.RespData(c, nil, err)
		return
	}
	listByUserID, err := coupon2.GoodsOrderCouponList(coupon)
	if err != nil {
		base.RespData(c, nil, err)
		return
	}
	base.RespData(c, listByUserID, err)
}

func UserCenterCouponList(c *gin.Context) {
	var userList formdata.UserCenterCouponList
	if err := c.ShouldBindJSON(&userList); err != nil {
		base.RespData(c, nil, err)
		return
	}
	listUserByUserID, err := coupon2.UserCenterCouponList(userList)
	if err != nil {
		base.RespData(c, nil, err)
		return
	}
	base.RespData(c, listUserByUserID, err)
}

func MemberList(c *gin.Context) {
	memberList, err := coupon2.MemberList()
	if err != nil {
		base.RespData(c, nil, err)
		return
	}
	base.RespData(c, memberList, err)
}

func PointsList(c *gin.Context) {
	list, err := coupon2.PointsList()
	if err != nil {
		base.RespData(c, nil, err)
		return
	}

	base.RespData(c, list, err)
}

func PointsInfo(c *gin.Context) {
	var pointsByID formdata.PointsInfo
	if err := c.ShouldBindJSON(&pointsByID); err != nil {
		base.RespData(c, nil, err)
		return
	}
	points, err := coupon2.PointsInfo(pointsByID)
	if err != nil {
		base.RespData(c, nil, err)
		return
	}
	base.RespData(c, points, err)
}
